import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { FactoryClassRecord, FactoryClassType } from "@/api/backend/index";
import qs from "qs";

export const useFactoryEquipmenClass = defineStore(Names.factoryC, {
  state: () => {
    return {
      id: 0,
      single: {},
      equipmentScheduleInfo: {},
      backupSearch: {},
    };
  },
  getters: {},
  actions: {
    //设备排班
    scheduling(filter: any) {
      return new Promise((resolve, reject) => {
        _get(
          FactoryClassType +
            "/list?" +
            qs.stringify(filter, { arrayFormat: "repeat" }),
          {},
          "json",
          ""
        )
          .then(async (res: any) => {
            console.log("设备排班", res);
            resolve(res);
          })
          .catch((err) => {
            reject(err);
          });
      });
    },
    //设备排班记录
    getScheduleRecord(filter: any) {
      return new Promise((resolve, reject) => {
        _get(FactoryClassRecord + "/list", filter, "json", "")
          .then(async (res: any) => {
            console.log("设备排班记录", res);
            resolve(res);
          })
          .catch((err) => {
            reject(err);
          });
      });
    },
  },
});
